//
//  UIScrollView+Refresh.h
//  ToolHelper
//
//  Created by liaozhenming on 16/5/18.
//  Copyright © 2016年 liaozhenming. All rights reserved.
//

#import <UIKit/UIKit.h>

@class UIScrollViewRefreshHeaderView;
@class UIScrollViewRefreshFooterView;

typedef void(^UIScrollViewDidRefreshEventHandle)(void);    /**< 重新加载*/
typedef void(^UIScrollViewDidLoadingEventHandle)(void);    /**< 加载更多*/

typedef NS_ENUM(NSUInteger,UIScrollViewRefreshState) {
    UIScrollViewRefreshStateNormal = 0,
    UIScrollViewRefreshStateRefreshing = 1,
};

@interface UIScrollView (Refresh)

@property (nonatomic, copy) UIScrollViewDidRefreshEventHandle kk_refreshEventHandle;  /**< 重新加载*/
@property (nonatomic, copy) UIScrollViewDidLoadingEventHandle kk_loadingEventHandle;  /**< 加载更多*/

@property (nonatomic, assign) BOOL kk_autoLoading;  /**<设置为自动加载更多*/
@property (nonatomic, assign) UIEdgeInsets kk_settingInset; /**< 该值第一次使用时会自动计算*/

@property (nonatomic, assign) UIScrollViewRefreshState kk_refreshState;

@property (nonatomic, strong) UIScrollViewRefreshHeaderView *headerView;
@property (nonatomic, strong) UIScrollViewRefreshFooterView *footerView;

- (void)kk_reloadData;

@end


#pragma mark -
#pragma mark - UIScrollViewRefreshView methods

@interface UIScrollViewRefreshView : UIView

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIActivityIndicatorView *loadingActivity;
@property (nonatomic, strong) UILabel *lastLoadingTime;

@property (nonatomic, readonly) BOOL isLoading;

+ (instancetype)createView;

- (void)startLoading;
- (void)stopLoading;

@end


@interface UIScrollViewRefreshHeaderView : UIScrollViewRefreshView


@end


@interface UIScrollViewRefreshFooterView : UIScrollViewRefreshView

@end
